Skip to content

refactor(types): export PermissionResolverParams + surface defaultDecision (SD-673)#3504

Merged
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/SD-export-permission-resolver-params
May 26, 2026
Merged

refactor(types): export PermissionResolverParams + surface defaultDecision (SD-673)#3504
caio-pizzol merged 1 commit into
mainfrom
caio-pizzol/SD-export-permission-resolver-params

Conversation

@caio-pizzol

Copy link
Copy Markdown
Contributor

Promotes PermissionResolverParams from a non-exported type alias to an exported interface so consumers can import the resolver-callback contract by name. Today, resolver authors have to either rely on Config.permissionResolver inference or write Parameters<NonNullable<Config['permissionResolver']>>[0] — neither is discoverable.

One real omission landed alongside the export. The runtime always forwards defaultDecision: boolean to the resolver (computed locally in permissions.js:isAllowed), but the non-exported helper omitted it. Resolver authors who wanted to defer to (or branch off) the built-in policy had to re-derive it. Adding it surfaces the value at the type level.

Field-presence tightened to match runtime exactly. The runtime spreads every field into the object literal it passes to the resolver, so every key is always present. role and isInternal can hold undefined values; comment, trackedChange, currentUser, and superdoc are coalesced to null and never undefined. Switched from optional (?:) properties to non-optional with explicit | undefined / | null types so the type reflects what the resolver actually receives, not what the consumer might construct. This is a tighter contract — existing resolvers reading these fields with params.role continue to work because string | undefined is structurally the same for reads.

Distinct from CanPerformPermissionParams (consumer input shape):

  • CanPerformPermissionParams is what consumers pass into SuperDoc#canPerformPermission.
  • PermissionResolverParams is what consumer resolvers receive, enriched with defaultDecision, currentUser, and superdoc.

Also fixes a stale doc on CanPerformPermissionParams that still referred to PermissionResolverParams as "non-exported" — that became false in this PR.

Consumer fixture (permission-resolver-params-apis.ts) asserts both resolver slots use the named type:

  • Config.permissionResolver
  • Modules.comments.permissionResolver

Drift between the two slots would slip past the public-method-coverage gate (callbacks aren't gate-tracked) but fails on AssertEqual here.

Stacked on #3503; retarget to main after that PR merges.

Verified: pnpm check:types -> PASS; pnpm check:public:superdoc --skip-build -> PASS (9 ran, 1 skipped, 129.6s); pnpm --filter superdoc test --run -> PASS (1054/1054).

…ision (SD-673)

Promotes PermissionResolverParams from a non-exported type alias to
an exported interface so consumers can import the resolver-callback
contract by name. Currently consumers writing a resolver have to
either rely on Config.permissionResolver inference or use
Parameters<NonNullable<Config['permissionResolver']>>[0]; both are
clumsy and neither is discoverable.

One real omission landed alongside the export: the runtime always
forwards defaultDecision: boolean to the resolver (computed locally
in permissions.js:isAllowed). The non-exported helper omitted it, so
resolver authors who wanted to defer to (or branch off) the built-in
policy had to re-derive it.

Field-presence tightened to match runtime exactly. The runtime
spreads every field into the object literal it passes to the
resolver, so every key is always present. role and isInternal can
hold undefined values; comment, trackedChange, currentUser, and
superdoc are coalesced to null and never undefined. Switched from
optional (?:) properties to non-optional with explicit
| undefined / | null types so the type reflects what the resolver
actually receives, not what the consumer might construct.

Distinct from CanPerformPermissionParams (consumer input shape):
- CanPerformPermissionParams is what consumers pass INTO
  SuperDoc#canPerformPermission.
- PermissionResolverParams is what consumer resolvers RECEIVE,
  enriched with defaultDecision, currentUser, and superdoc.
Also fixes the CanPerformPermissionParams doc that still referred to
PermissionResolverParams as 'non-exported.'

Consumer fixture (permission-resolver-params-apis.ts) asserts both
resolver slots use the named type:
- Config.permissionResolver
- Modules.comments.permissionResolver

Verified: pnpm check:types -> PASS; pnpm check:public:superdoc
--skip-build -> PASS (9 ran, 1 skipped, 129.6s).
@caio-pizzol
caio-pizzol requested a review from a team as a code owner May 26, 2026 12:08
@linear-code

linear-code Bot commented May 26, 2026

Copy link
Copy Markdown

SD-673

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 8 files

Re-trigger cubic

Base automatically changed from caio-pizzol/SD-typed-callback-bridge to main May 26, 2026 16:16
@caio-pizzol
caio-pizzol merged commit 20f00c6 into main May 26, 2026
2 checks passed
@caio-pizzol
caio-pizzol deleted the caio-pizzol/SD-export-permission-resolver-params branch May 26, 2026 16:16
@superdoc-bot

superdoc-bot Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-cli v0.13.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc-sdk v1.12.0

@superdoc-bot

superdoc-bot Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/mcp v0.8.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in superdoc v1.36.0

The release is available on GitHub release

@superdoc-bot

superdoc-bot Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

🎉 This PR is included in @superdoc-dev/react v1.7.0

The release is available on GitHub release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant